

package com.hazelcast.internal.ascii.memcache;

import com.hazelcast.internal.ascii.TextCommand;
import com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType;
import com.hazelcast.internal.ascii.TypeAwareCommandParser;
import com.hazelcast.internal.nio.ascii.TextDecoder;

import static com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.*;

public class SimpleCommandParser extends TypeAwareCommandParser {

    public SimpleCommandParser(TextCommandType type) {
        super(type);
    }

    @Override
    public TextCommand parser(TextDecoder decoder, String cmd, int space) {
        if (type == QUIT) {
            return new SimpleCommand(type);
        } else
            if (type == STATS) {
                return new StatsCommand();
            } else
                if (type == VERSION) {
                    return new VersionCommand(type);
                } else {
                    return new ErrorCommand(UNKNOWN);
                }
    }
}
